#ifndef PEER_H
#define PEER_H

#include "node.h"
#include "channel.h"
#include "port.h"

#include "ip/softmem.h"

#include "ip/erunner.h"

#include "ip/mrunner.h"

#include "ip/alu.h"

#include "ip/and_gate.h"

#include "ip/fabrics.h"

typedef struct NodePeerParam
{
    int peer_id;
    int softmem_size;
    int num_of_main_memory;
    int num_of_alu;
    int multiplexer;
    int total_peers;
    List<int> base_ptrs;
} NodePeerParam;

class NodePeer : public Node
{
public:
    int const_peer_id;
    ChannelExecOpFabricReceiver * port_nano_op_receiver;
    List<ChannelLoadFabricReceiver *> port_memory_receivers;
    List<ChannelStoreFabricSender *> port_memory_senders;
    ChannelLoadFabricSender * port_chain_out;
    ChannelLoadFabricReceiver * port_chain_in;
    PortOut<bool> * port_halt;
    NodeSoftmem * node_softmem;
    NodeERunner * node_erunner;
    NodeMRunner * node_mrunner;
    List<NodeAlu *> node_alus;
    NodeAndGate * node_halt_detect;

    NodePeer(Node *parent, NodePeerParam params);
    NodeTaskList tasks() const override;
};

#endif // PEER_H